import Loading from "@/components/Loading";
import React, { LazyExoticComponent, Suspense } from "react";
import { lazy } from "react";
import { Navigate, RouteObject, createBrowserRouter } from "react-router-dom";
const componentLoading = (children: LazyExoticComponent<React.FC>) => {
    return (
        <Suspense fallback={<Loading />}>{React.createElement(children)}</Suspense>
    );
};
const routes: RouteObject[] = [
    {
        path: "/",
        element: <Navigate to="/home"></Navigate>,
    },
    {
        path: "/home",
        element: componentLoading(lazy(() => import("@/pages/home"))),
    },
    {
        path: "/municipal-works",
        element: componentLoading(lazy(() => import("@/pages/municipal-works")))
    },
    {
        path: "/smart-city",
        element: componentLoading(lazy(() => import("@/pages/smart-city"))),
    },
    {
        path: "/smart-light",
        element: componentLoading(lazy(() => import("@/pages/smart-light"))),
    },
];
const router = createBrowserRouter(routes);
export default router;
export { routes };
